package tech.aistar.corejava.day15;

/**
 * Created by 豆梦寒 on 2019/8/3.
 */
public class RunableDemo implements Runnable{

    @Override
    public void run() {
        for (int i=0;i<10;i++){
            //返回的是当前执行的线程的引用的名称
            //名称不指定 系统会默认分配一个
            System.out.println(Thread.currentThread().getName()+"::"+i);

            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
class TestRunableDemo{
    public static void main(String[] args) {
        Runnable r = new RunableDemo();

        //创建线程对象
        Thread t1= new Thread(r);
        Thread t2 = new Thread(r);

        t1.start();
        t2.start();
    }
}